package pers.wensheng.patterns.behavioral_pattern.memento_pattern.white_box;

import lombok.Data;

/**
 * 发起人
 * 游戏角色
 */
@Data
public class GameRole {
    private int vit; //生命力
    private int atk; //攻击力
    private int def; //防御力

    /**
     * 初始状态
     */
    public void initState(){
        this.vit = 100;
        this.atk = 100;
        this.def = 100;
    }

    /**
     * 战斗以后
     */
    public void fight(){
        this.vit = 0;
        this.atk = 0;
        this.def = 0;
    }

    /**
     * 保存角色状态
     */
    public RoleStateMemento saveState(){
        return new RoleStateMemento(vit,atk,def);
    }

    /**
     * 恢复角色状态
     * @param roleStateMemento
     */
    public void recoverState(RoleStateMemento roleStateMemento){
        this.vit = roleStateMemento.getVit();
        this.atk = roleStateMemento.getAtk();
        this.def = roleStateMemento.getDef();
    }

}
